package com.adapter.demo1.main;

import com.adapter.demo1.TurkeyAdapter;
import com.adapter.demo1.face.Duck;
import com.adapter.demo1.face.Turkey;
import com.adapter.demo1.impl.MallardDuck;
import com.adapter.demo1.impl.WildTurkey;

/**
 * 适配器模式：将一个类的接口，转换成客户期望的另一个接口。适配器让原本接口不兼容的类可以合作无间
 * 
 * @author dell
 * 
 */
public class DuckTestDrive {

	public static void main(String[] args) {
		// 鸭子
		Duck duck = new MallardDuck();
		// 火鸡
		Turkey turkey = new WildTurkey();
		Duck turkeyAdapter = new TurkeyAdapter(turkey);

		System.out.println("The Turkey says...");
		turkey.gobble();
		turkey.fly();

		System.out.println("\nThe Duck says...");
		testDuck(duck);

		System.out.println("\nThe TurkeyAdapter says...");
		testDuck(turkeyAdapter);
	}

	static void testDuck(Duck duck) {
		duck.quack();
		duck.fly();
	}

}
